package org.itboys.core.service.mongo.front;

import org.itboys.core.common.SundayCommonConstants;
import org.itboys.core.entity.mongo.SundayCenterMessage;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseMongoService;
import org.itboys.param.ParamUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * Auther: 罗尧坤
 * Date: 2018/8/16
 * Description: 消息中心服务类
*/

@Service
public class SundayFrontCenterMessageService extends BaseMongoService<SundayCenterMessage> {
    @Resource(name = "mobileDs")
    private MongoDataSource mongoDataSource;

    @Override
    protected MongoDataSource getMongoDataSource() {
        return mongoDataSource;
    }

    @Override
    protected Class<SundayCenterMessage> getEntityClass() {
        return SundayCenterMessage.class;
    }

    /**
     * 获取消息列表
     * @param request
     * @param memberId
     * @return
     */
    public List<SundayCenterMessage> select(HttpServletRequest request, Long memberId){
        Map<String, Object> param = ParamUtil.packageMongoExactParam(request);
        param.put("isDeleted", SundayCommonConstants.NO);
        param.put("memberId", memberId);
        param.put("status", SundayCommonConstants.YES);

        List<SundayCenterMessage> list = super.pageQuery(request, param).getData();

        return list;
    }

    /**
     * 查询详细消息
     * @param id
     * @return
     */
    public SundayCenterMessage getDetail(Long id){
        return super.getById(id);
    }

}
